#include <sstream>
#include "Exceptions.hpp"

namespace red{
	Exception::Exception(const std::string &pMsg) : mMessage(pMsg){
	}

	Exception::~Exception() throw(){
	}

	const char* Exception::what() const throw(){
		return mMessage.c_str();
	}

	AssertException::AssertException(const std::string &pFile, int pLine, const std::string &pMsg){
		std::ostringstream oss;
		oss << pFile << "( " << pLine << " ) :" << std::endl;
		oss << pMsg << std::endl;

		mMessage = oss.str();
	}

	BadDelete::BadDelete(unsigned long ptr, const std::string &pFile, int pLine, bool pNewArray){
		std::ostringstream oss;
		oss << "Anomalie "
        << (pNewArray ? "new[] / delete" :  "new / delete[]")
        << " detectee" << std::endl << std::endl
        << "Adresse : 0x" << ptr << std::endl
        << "Fichier source : " << pFile << " (" << pLine << ")";

		mMessage = oss.str();
	}

	LoadingFailed::LoadingFailed(const std::string &pFile, const std::string &pMsg){
		std::ostringstream oss;
		oss << "Error in the loading of " << pFile << std::endl << pMsg;

		mMessage = oss.str();
	}

	LuaException::LuaException(const std::string &pFunction, const std::string &pMsg){
		std::ostringstream oss;
		oss << "-- Lua Error (" << pFunction << ") : " << pMsg;

		mMessage = oss.str();
	}
}
